package indi.h.filefilter;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import indi.h.filefilter.callables.InterceptorCallable;
import indi.h.filefilter.filters.Filter;
import indi.h.filefilter.listeners.InterceptorListener;

public class InterceptorThreadPool {
	private ExecutorService es;
	private ExecutorCompletionService<Filter.FilterR> ecs;
	private InterceptorListener il;

	public InterceptorThreadPool() {
		int cpu = Runtime.getRuntime().availableProcessors();
		es = Executors.newFixedThreadPool(cpu);
		ecs = new ExecutorCompletionService<Filter.FilterR>(es);
	}

	public InterceptorThreadPool(int size) {
		es = Executors.newFixedThreadPool(size);
		ecs = new ExecutorCompletionService<Filter.FilterR>(es);
	}

	public void setGInterceptorListener(InterceptorListener il) {
		this.il = il;
	}

	public void exec(Callable c) {
		es.submit(c);
	}

}
